class ServiciosController < ApplicationController
	layout 'proveedores'
  # GET /servicios
  # GET /servicios.xml
  def index  	
    @servicios = Servicio.find(:all)

    respond_to do |format|
      format.html # index.rhtml
      format.xml  { render :xml => @servicios.to_xml }
    end
  end

  # GET /servicios/1
  # GET /servicios/1.xml
  def show
    @servicio = Servicio.find(params[:id])

    respond_to do |format|
      format.html # show.rhtml
      format.xml  { render :xml => @servicio.to_xml }
    end
  end

  # GET /servicios/new
  def new
    @servicio = Servicio.new(:proveedor_id => params[:proveedor_id])
  end

  # GET /servicios/1;edit
  def edit
    @servicio = Servicio.find(params[:id])
  end

  # POST /servicios
  # POST /servicios.xml
  def create
    @servicio = Servicio.new(params[:servicio])
    @servicio.proveedor_id = params[:proveedor_id]

    respond_to do |format|
      if @servicio.save
        flash[:notice] = 'Servicio was successfully created.'
        format.html { redirect_to servicio_url(params[:proveedor_id], @servicio) }
        format.xml  { head :created, :location => servicio_url(@servicio) }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @servicio.errors.to_xml }
      end
    end
  end

  # PUT /servicios/1
  # PUT /servicios/1.xml
  def update
    @servicio = Servicio.find(params[:id])

    respond_to do |format|
      if @servicio.update_attributes(params[:servicio])
        flash[:notice] = 'Servicio was successfully updated.'
        format.html { redirect_to servicio_url(params[:proveedor_id], @servicio) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @servicio.errors.to_xml }
      end
    end
  end

  # DELETE /servicios/1
  # DELETE /servicios/1.xml
  def destroy
    @servicio = Servicio.find(params[:id])
    @servicio.destroy

    respond_to do |format|
      format.html { redirect_to proveedor_url(params[:proveedor_id]) }
      format.xml  { head :ok }
    end
  end
end
